// data interpolated from vertex program output
struct vertexIN
{
  float3 objectSpacePos : TEXCOORD1;
  float3 normal   		: TEXCOORD2;
  float4 color			: COLOR;
};

float3 main(vertexIN vIn, uniform float4 lightPosition) : COLOR
{
  // P: Object position
  // L: Light incoming vector,
  // N: Normal.
  float3 P = vIn.objectSpacePos.xyz;
  float3 N = normalize(vIn.normal);
  float3 L = normalize(lightPosition.xyz - P);
  
  float intensity = dot(L,N);
  
  float colorFactor;
  if (intensity > 0.95)
  {
  	colorFactor = 1.0;
  }
  else if (intensity > 0.5)
  {
  	colorFactor = 0.75;
  }
  else
  {
  	colorFactor = 0.5;
  }
  
  // Part 1: 
  // return colorFactor*float4(1.0, 1.0, 1.0);
  
  // Part 2:
  return colorFactor*vIn.color;  
}